package com.atguigu.cf.test;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;

/**
 * author: 封捷
 * date: 2023/1/29 16:44
 * version: 1.0
 */
public class Demo04TaskThenAccept {

    public static void main(String[] args) {

        ExecutorService threadPool = ThreadPoolProvider.getThreadPool();

        // 后面任务接收前面任务结果，但是后面任务自己没有结果返回
        CompletableFuture
                .supplyAsync(() -> "task prev result", threadPool)
                .thenAccept(prevTaskResult -> {
                    System.out.println("这里是第二个任务，前面任务的结果是：" + prevTaskResult);
                });

    }

}
